package com.lanp.gencode.test;


import com.alibaba.fastjson.JSON;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpObject;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpResponse;
import org.littleshoot.proxy.HttpFiltersAdapter;

public class MyHttpFiltersAdapter extends HttpFiltersAdapter {


    public MyHttpFiltersAdapter(HttpRequest originalRequest, ChannelHandlerContext ctx) {
        super(originalRequest, ctx);
    }

    public MyHttpFiltersAdapter(HttpRequest originalRequest) {
        super(originalRequest);
    }

    @Override
    public HttpObject proxyToClientResponse(HttpObject httpObject) {
        System.out.println("--------- proxyToClientResponse ---------");
        System.out.println("proxyToClientResponse = "+ JSON.toJSONString(httpObject));
        return super.proxyToClientResponse(httpObject);
    }

    @Override
    public HttpResponse proxyToServerRequest(HttpObject httpObject) {
        System.out.println("--------- proxyToServerRequest ---------");
        System.out.println("proxyToServerRequest = "+ JSON.toJSONString(httpObject));
        return super.proxyToServerRequest(httpObject);
    }
    @Override
    public HttpResponse clientToProxyRequest(HttpObject httpObject) {
        System.out.println("--------- clientToProxyRequest ---------");
        System.out.println("clientToProxyRequest = "+ JSON.toJSONString(httpObject));
        return null;
    }
    @Override
    public HttpObject serverToProxyResponse(HttpObject httpObject) {
        System.out.println("--------- serverToProxyResponse ---------");
        System.out.println("serverToProxyResponse = "+ JSON.toJSONString(httpObject));
        return httpObject;
    }

}
